package cn.sdhuijin.vms.model;

import java.util.Calendar;

import javax.persistence.Entity;
import javax.persistence.JoinColumn;
import javax.persistence.ManyToOne;
import javax.persistence.Table;

@Entity
@Table(name = "t_person_record")
public class PersonRecord extends Record {

	/**
	 * 
	 */
	private static final long serialVersionUID = 1L;
	@ManyToOne
	@JoinColumn(name = "person_id")
	private Person person;
	@ManyToOne
	@JoinColumn(name = "leave_id")
	private Leave leave;

	public String getWarn() {
		String type = "正常";
		Calendar cld = Calendar.getInstance();
		cld.setTime(getDate());
		Integer hour = Integer.valueOf(cld.get(11));
		Integer day = Integer.valueOf(cld.get(7));
		if ((day.intValue() == 7) || (day.intValue() == 1)
				|| (hour.intValue() >= 18) || (hour.intValue() < 8))
			if (this.leave == null) {
				type = "违规：无申请";
			} else {
				ApproveStatus status = this.leave.getStatus();
				switch (status) {
				case DISAGREE:
					type = "违规：申请被拒绝";
					break;
				case UNTREATED:
					type = "违规：申请未处理";
					break;
				default:
					break;
				}

			}

		return type;
	}

	public Person getPerson() {
		return person;
	}

	public void setPerson(Person person) {
		this.person = person;
	}

	public Leave getLeave() {
		return leave;
	}

	public void setLeave(Leave leave) {
		this.leave = leave;
	}
}
